import Vue from 'vue'
import Router from 'vue-router'
import Hello from '@/components/Hello'
import Home from '@/pages/Home'

Vue.use(Router)

const router = new Router({
  routes: [
    {
      path: '/hello',
      name: 'Hello',
      component: Hello
    },
    {
      path: '/',
      name: 'Home',
      component: Home
    }
  ]
})

// window.$http_able = false
router.beforeEach((to, from, next) => {
  next()
})

// 在路由到新界面后,将窗口重置到界面顶部。
router.afterEach((to, from) => {
  window.scrollTo(0, 0)
})

export default router
